{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Separate the Digits in an Array"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #simulation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #模拟"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: separateDigits"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #分割数组中数字的数位"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个正整数数组&nbsp;<code>nums</code>&nbsp;，请你返回一个数组<em>&nbsp;</em><code>answer</code> ，你需要将&nbsp;<code>nums</code>&nbsp;中每个整数进行数位分割后，按照&nbsp;<code>nums</code>&nbsp;中出现的&nbsp;<strong>相同顺序</strong>&nbsp;放入答案数组中。</p>\n",
    "\n",
    "<p>对一个整数进行数位分割，指的是将整数各个数位按原本出现的顺序排列成数组。</p>\n",
    "\n",
    "<ul>\n",
    "\t<li>比方说，整数&nbsp;<code>10921</code>&nbsp;，分割它的各个数位得到&nbsp;<code>[1,0,9,2,1]</code>&nbsp;。</li>\n",
    "</ul>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><b>输入：</b>nums = [13,25,83,77]\n",
    "<b>输出：</b>[1,3,2,5,8,3,7,7]\n",
    "<b>解释：</b>\n",
    "- 分割 13 得到 [1,3] 。\n",
    "- 分割 25 得到 [2,5] 。\n",
    "- 分割 83 得到 [8,3] 。\n",
    "- 分割 77 得到 [7,7] 。\n",
    "answer = [1,3,2,5,8,3,7,7] 。answer 中的数字分割结果按照原数字在数组中的相同顺序排列。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><b>输入：</b>nums = [7,1,3,9]\n",
    "<b>输出：</b>[7,1,3,9]\n",
    "<b>解释：</b>nums 中每个整数的分割是它自己。\n",
    "answer = [7,1,3,9] 。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= nums.length &lt;= 1000</code></li>\n",
    "\t<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [separate-the-digits-in-an-array](https://leetcode.cn/problems/separate-the-digits-in-an-array/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [separate-the-digits-in-an-array](https://leetcode.cn/problems/separate-the-digits-in-an-array/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[13,25,83,77]', '[7,1,3,9]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        # res = []\n",
    "        # for i in nums:\n",
    "        #     res.extend([int(j) for j in str(i)])\n",
    "        # return res \n",
    "\n",
    "        # --------------------\n",
    "        return [d for x in nums for d in map(int, str(x))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        # 倒序插入\n",
    "        for i in range(len(nums)-1, -1, -1):\n",
    "            tmp = []\n",
    "            while nums[i]!=0:\n",
    "                tmp.append(nums[i]%10)\n",
    "                nums[i]=nums[i]//10\n",
    "            nums = nums[:i]+tmp[::-1]+nums[i+1:]\n",
    "        return nums\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans=[]\n",
    "        for i in nums:\n",
    "            for j in str(i):\n",
    "                ans.append(int(j))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for v in nums:\n",
    "            t = []\n",
    "            while v:\n",
    "                t.append(v % 10)\n",
    "                v //= 10\n",
    "            ans.extend(t[::-1])\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for n in nums:\n",
    "            for c in str(n):\n",
    "                res.append(int(c))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        # res = []\n",
    "        # for num in nums:\n",
    "        #     t = len(res)\n",
    "        #     while num:\n",
    "        #         res.append(num % 10)\n",
    "        #         num //= 10\n",
    "        #     res[t:] = res[t:][::-1]\n",
    "        # return res\n",
    "        return [d for t in nums for d in map(int, str(t))]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for i in nums:\n",
    "            l = []\n",
    "            while i >= 10:\n",
    "                l.append(i % 10)\n",
    "                i = i // 10\n",
    "            l.append(i)\n",
    "            l.reverse()\n",
    "            ans.extend(l)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(i) for num in nums for i in str(num)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [d for x in nums for d in map(int, str(x))]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for i in nums:\n",
    "            temp = []\n",
    "            while i > 0:\n",
    "                temp.append(i%10)\n",
    "                i //= 10\n",
    "            res += temp[::-1]\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "def func(n):\n",
    "    if n==0:\n",
    "        return [0]\n",
    "    ret = []\n",
    "    while n!=0:\n",
    "        n,ys = divmod(n,10)\n",
    "        ret.append(ys)\n",
    "    return ret[::-1]\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ret = []\n",
    "        for n in nums:\n",
    "            ret += func(n)\n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for i in nums:\n",
    "            tmp = []\n",
    "            while i > 0:\n",
    "                tmp.append(i%10)\n",
    "                i//=10\n",
    "            res += tmp[::-1]\n",
    "        return res\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(j) for i in nums for j in str(i)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        strlist = ''\n",
    "        for l in nums:\n",
    "            strlist += str(l)\n",
    "        res = []\n",
    "        for s in strlist:\n",
    "            res.append(int(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            num = str(num)\n",
    "            for i in num:\n",
    "                ans.append(int(i))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [j for i in nums for j in map(int,str(i))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [d for x in nums for d in map(int, str(x))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for v in nums:\n",
    "            for e in str(v):\n",
    "                res.append(int(e))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            s = str(num)\n",
    "            for i in range(len(s)):\n",
    "                ans.append(int(s[i]))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for i in nums:\n",
    "            x = i\n",
    "            ar = deque()\n",
    "            while x:\n",
    "                x, a = divmod(x, 10)\n",
    "                ar.appendleft(a)\n",
    "            res.extend(ar)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for i in nums:\n",
    "            index = len(ans)\n",
    "            while i>0:\n",
    "                ans.append(i%10)\n",
    "                i=i//10\n",
    "            ans[index:] = ans[index:][::-1]\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        s = str()\n",
    "        for i in nums:\n",
    "            for j in str(i):\n",
    "                s += j\n",
    "        ans = []\n",
    "        for i in s:\n",
    "            ans.append(int(i))\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans=[]\n",
    "        for num in nums:\n",
    "            ans.extend(list(str(num)))\n",
    "        \n",
    "        return [int(a) for a in ans]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [d for x in nums for d in map(int, str(x))]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        answer1=[]\n",
    "        answer=[]\n",
    "        for i in nums:\n",
    "            answer1.append(str(i))\n",
    "        for j in answer1:\n",
    "            for k in range(0,len(j)):\n",
    "                answer.append(int(j[k]))\n",
    "        return answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans=[]\n",
    "        for i in nums:\n",
    "            for j in str(i):\n",
    "                ans.append(int(j))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "      result = []\n",
    "      for i in nums:\n",
    "        temp = re.split('',str(i))\n",
    "        temp.pop(0)\n",
    "        temp.pop()\n",
    "        for j in temp:\n",
    "          result.append(int(j))\n",
    "      return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        n=len(nums)\n",
    "        res=[]\n",
    "        for i in range(n):\n",
    "            for s in str(nums[i]):\n",
    "                res+=[int(s)]\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        answer=[]\n",
    "        answer2=[]\n",
    "        for i in nums:\n",
    "            for j in str(i):\n",
    "                answer.append(j)\n",
    "        for i in answer:\n",
    "            i=int(i)\n",
    "            answer2.append(i)\n",
    "        return answer2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for n in nums:\n",
    "            ans += list(map(int, str(n)))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(x) for i in range(len(nums)) for x in str(nums[i])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            tmp = []\n",
    "            while num:\n",
    "                tmp.append(num % 10)\n",
    "                num //= 10\n",
    "            ans += tmp[::-1]\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            n = []\n",
    "            while num//10 >0:\n",
    "                n.append(num%10)\n",
    "                num //= 10\n",
    "            n.append(num%10)\n",
    "            ans += n[::-1]\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for x in nums:\n",
    "            for y in str(x):\n",
    "                ans.append(int(y))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return sum((list(map(int, str(x))) for x in nums), [])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        # res = []\n",
    "        # for i in nums:\n",
    "        #     res.extend([int(j) for j in str(i)])\n",
    "        # return res \n",
    "\n",
    "        # --------------------\n",
    "        # return [d for x in nums for d in map(int, str(x))]\n",
    "\n",
    "        # --------------------------\n",
    "        res = []\n",
    "        for x in nums:\n",
    "            i = len(res)\n",
    "            while x:\n",
    "                res.append(x%10)\n",
    "                x //= 10\n",
    "            res[i:] = res[i:][::-1]\n",
    "        return res "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(j) for j in ''.join(str(i) for i in nums)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\r\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\r\n",
    "        def decimal(n):\r\n",
    "            condition = list()\r\n",
    "            while n // 10 != 0:\r\n",
    "                condition.append(n%10)\r\n",
    "                n = n // 10\r\n",
    "            condition.append(n)\r\n",
    "            return condition[::-1]\r\n",
    "        ans = list()\r\n",
    "        for i in nums:\r\n",
    "            ans += decimal(i)\r\n",
    "        return ans \r\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        s = []\n",
    "        for x in nums:\n",
    "            while x:\n",
    "                s.append(x % 10)\n",
    "                x //= 10\n",
    "            while s:\n",
    "                ans.append(s.pop())\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, a: List[int]) -> List[int]:\n",
    "        ans=[]\n",
    "        for i in a:\n",
    "            for j in str(i):\n",
    "                ans.append(ord(j)-ord('0'))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for n in nums:\n",
    "            tmp = []\n",
    "            while n!=0:\n",
    "                tmp.append(n%10)\n",
    "                n //= 10\n",
    "            ans.extend(tmp[::-1])\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ret=[]\n",
    "        for i in nums:\n",
    "            if i>=0 and i<=9:\n",
    "                ret.append(i)\n",
    "            else:\n",
    "                x=i\n",
    "                get=[]\n",
    "                while x>0:\n",
    "                    get.append(x%10)\n",
    "                    x=int(x/10)\n",
    "                get=get[::-1]\n",
    "                for c in get:\n",
    "                    ret.append(c)\n",
    "        return ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        l=[str(i) for i in nums]\n",
    "        s=[]\n",
    "        for i in l:\n",
    "            for j in i:\n",
    "                s.append(j)\n",
    "        s=[int(i) for i in s]\n",
    "        return s\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "       return [d for x in nums for d in map(int, str(x))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "      ls=[]\n",
    "      for n in nums:\n",
    "        tp=str(n)\n",
    "        for ch in tp:\n",
    "          ls.append(int(ch))\n",
    "      return ls"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [d for x in nums for d in map(int, str(x))]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for num in nums:\n",
    "            t = len(res)\n",
    "            while num:\n",
    "                res.append(num % 10)\n",
    "                num //= 10\n",
    "            res[t:] = res[t:][::-1]\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        n = len(nums)\n",
    "        for i in range(n-1,-1,-1):\n",
    "            a = nums[i]\n",
    "            while a > 0:\n",
    "                b = a % 10\n",
    "                ans.append(b)\n",
    "                a //= 10\n",
    "        ans.reverse()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(n) for num in nums for n in str(num)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        def get_byte(num):\n",
    "            ret = []\n",
    "            while num:\n",
    "                num, byte = divmod(num, 10)\n",
    "                ret.append(byte)\n",
    "            return reversed(ret)\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            num_byte = get_byte(num)\n",
    "            ans.extend(num_byte)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(n) for num in nums for n in str(num)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "      d =[]\n",
    "      for i in nums:\n",
    "        a = str(i)\n",
    "        b = list(a)\n",
    "        for c in b:\n",
    "          e = int(c)\n",
    "          d.append(e)\n",
    "      return d\n",
    "        \n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        def cut(n):\n",
    "            ans = []\n",
    "            while n:\n",
    "                ans.append(n % 10)\n",
    "                n //= 10\n",
    "            return ans[::-1]\n",
    "        \n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            ans += cut(num)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "\n",
    "        digits = []\n",
    "\n",
    "        for num in nums:\n",
    "            num_str = str(num)\n",
    "            for letter in num_str:\n",
    "                digits.append(int(letter))\n",
    "        \n",
    "        return digits"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for num in nums:\n",
    "            nn = list(str(num))\n",
    "            res += [int(n) for n in nn]\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        a=[]\n",
    "        for i in nums:\n",
    "            b=str(i)\n",
    "            for j in b:\n",
    "                a.append(int(j))\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(x) for x in list(\"\".join([str(x) for x in nums]))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        answer = []\n",
    "        for num in nums:\n",
    "            digits = list(str(num))\n",
    "            for i in digits:\n",
    "                answer.append(int(i))\n",
    "        return answer\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for num in reversed(nums):\n",
    "            while num >= 10:\n",
    "                ans.append(num % 10)\n",
    "                num = num // 10\n",
    "            ans.append(num)\n",
    "        return ans[::-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        s = \"\"\n",
    "        for num in nums:\n",
    "           s += str(num)\n",
    "\n",
    "        for string in s:\n",
    "            ans.append(int(string))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "      \n",
    "      return list(map(int,list(''.join(map(str,nums)))))\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for num in nums:\n",
    "            tmp_list = []\n",
    "            while num > 9:\n",
    "                tmp_list.append(num % 10)\n",
    "                num //= 10\n",
    "            tmp_list.append(num)\n",
    "            for idx in range(len(tmp_list) - 1, -1, -1):\n",
    "                res.append(tmp_list[idx])\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for x in nums:\n",
    "            res += [int(y) for y in str(x)]\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        alist = []\n",
    "        for item in nums:\n",
    "            s = str(item)\n",
    "            l = len(s)\n",
    "            for j in range(l):\n",
    "                alist.append(int(s[j]))\n",
    "        return alist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [d for x in nums for d in map(int, str(x))]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for x in nums[::-1]:\n",
    "            while x > 0:\n",
    "                ans.append(x%10)\n",
    "                x //= 10\n",
    "        return ans[::-1 ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        def check(num):\n",
    "            ret = []\n",
    "            while num != 0:\n",
    "                cur = num % 10\n",
    "                ret.append(cur)\n",
    "                num = num // 10\n",
    "            return ret[::-1]\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            ans.extend(check(num))\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        return [int(x) for x in (''.join([str(x) for x in nums]))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        answer=[]\n",
    "        start=0\n",
    "        for n in nums:\n",
    "            count=0\n",
    "            while n >= 10:\n",
    "                answer.insert(start,n%10)\n",
    "                count+=1\n",
    "                n=n//10\n",
    "            answer.insert(start, n)\n",
    "            count+=1\n",
    "            start+=count\n",
    "        return answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for n in nums:\n",
    "            res.extend(int(d) for d in str(n))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        nums = list(map(str, nums))\n",
    "        nums = ''.join(nums)\n",
    "        nums = list(map(int, list(nums)))\n",
    "\n",
    "        return nums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        answer=[]\n",
    "        for n in nums:\n",
    "            temp=[]\n",
    "            while n >= 10:\n",
    "                temp.insert(0,n%10)\n",
    "                n=n//10\n",
    "            temp.insert(0, n)\n",
    "            answer+=temp\n",
    "        return answer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        # answer=[]\n",
    "        # for num in nums:\n",
    "        #     str_num=str(num)\n",
    "        #     for i in range(len(str_num)):\n",
    "        #         answer.append(int(str_num[i]))\n",
    "        # return answer\n",
    "        ans = []\n",
    "        for num in nums:\n",
    "            temp = str(num)\n",
    "            for s in temp:\n",
    "                ans.append(int(s))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "      d =[]\n",
    "      for i in nums:\n",
    "        a = str(i)\n",
    "        b = list(a)\n",
    "        \n",
    "        for c in b:\n",
    "          e = int(c)\n",
    "          d.append(e)\n",
    "      return d\n",
    "        \n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from typing import List\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        result = []\n",
    "        for num in nums:\n",
    "            result.extend([int(digit) for digit in str(num)])\n",
    "        return result\n",
    "\n",
    "# 测试\n",
    "solution = Solution()\n",
    "print(solution.separateDigits([13,25,83,77]))  # 输出：[1,3,2,5,8,3,7,7]\n",
    "print(solution.separateDigits([7,1,3,9]))     # 输出：[7,1,3,9]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def separateDigits(self, nums: List[int]) -> List[int]:\n",
    "        ans=[]\n",
    "        for i in nums:\n",
    "            t=i\n",
    "            tp=[]\n",
    "            while t:\n",
    "                t,yu=divmod(t,10)\n",
    "                tp.append(yu)\n",
    "            ans+=tp[::-1]\n",
    "        return ans"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
